/*
 * logger.h
 *
 *  Created on: 2021年2月7日
 *      Author: kimfeng
 */

#ifndef LOG_LOGGER_H_
#define LOG_LOGGER_H_

#include <stdio.h>
#if defined(__MINGW64__) || defined(__MINGW32__)
#include <string>
#endif

#define _USE_SPDLOG_	0
#if _USE_SPDLOG_
#include <spdlog/spdlog.h>
#endif

typedef enum logger_level_e
{
	eNoLog = 0,
	eInfo,
	eError,
	eWarn,
	eDebug,
	eTrace,
	eUnknown,
}logger_level;

void logger_init(logger_level level = eError, bool bFlushNow = false);
void logger_init(const char *sLevel, bool bFlushNow = false);
void print_debug_message(int level, FILE *f, const char *filename, const char *func, int line, const char *fmt, ...);
logger_level get_logger_level_byname(const char *sLevel);
logger_level get_current_logger_level();

#define log_trace(fmt, ...)	print_debug_message(eTrace, stdout, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__)
#define log_debug(fmt, ...)	print_debug_message(eDebug, stdout, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__)
#define log_warn(fmt, ...)	print_debug_message(eWarn, stdout, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__)
#define log_error(fmt, ...)	print_debug_message(eError, stderr, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__)
#define log_info(fmt, ...)	print_debug_message(eInfo, stdout, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__)

#endif /* LOG_LOGGER_H_ */
